package com.hitrust.gs.dao;

import java.util.ArrayList;

import com.hitrust.gs.bean.GSFunctionBean;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.db.GSBaseDAO;

public class GSFunctionDAO extends GSBaseDAO{
    /**
     * 取得符合条件的功能清单
     * 
     * @param aMenuLevel 菜单等级 0：标签；1：一级菜单；2：二级菜单 
     * 
     * @return ArrayList 符合条件的功能清单，是FunctionBean对象
     */
    public ArrayList getFunctions(String aMenuLevel){
        if (aMenuLevel == null){
            return new ArrayList();
        }
        if (!(aMenuLevel.endsWith("0") || aMenuLevel.endsWith("1") || aMenuLevel.endsWith("2"))){
            return new ArrayList();
        }
        
        String tSql = "select * from GS_Function where gs_menu_level=? AND gs_disp_flag='1' order by gs_disp_no";
        GSFunctionBean tFunctionBean = new GSFunctionBean();
        Object[] tObj = new Object[1];
        tObj[0] = aMenuLevel;
        
        ArrayList tList = null;
        try {
            tList = executeQuery(tFunctionBean, tSql, tObj);
        } catch (Exception ex) {
            GSLogWriter.error(ex.getMessage());
            return new ArrayList();
        }
        
        if (tList == null) {
            tList = new ArrayList();
        }
        
        return tList;
    }
    
    
    /**
     * 取得所有非标签类型的功能清单
     * 
     * @return ArrayList 符合条件的功能清单，是FunctionBean对象
     */
    public ArrayList getFunctionsNotLabel(){
        String tSql = "select * from GS_Function where gs_menu_level!='0' AND gs_func_type!='0' AND gs_disp_flag='1' order by gs_disp_no";
        GSFunctionBean tFunctionBean = new GSFunctionBean();
        
        ArrayList tList = null;
        try {
            tList = executeQuery(tFunctionBean, tSql, null);
        } catch (Exception ex) {
            GSLogWriter.error(ex.getMessage());
            return new ArrayList();
        }
        
        if (tList == null) {
            tList = new ArrayList();
        }
        
        return tList;
    }
    
}
